<script setup lang="ts">
let controle1 = ref(1)
let controle2 = ref(2)
let controle3 = ref(3)
let controle4 = ref(4)

let controle1Fr = computed(() => {
  return controle1.value + 'fr'
})

let controle2Fr = computed(() => {
  return controle2.value + 'fr'
})

let controle3Fr = computed(() => {
  return '220px'
})

let controle4Fr = computed(() => {
  return controle4.value + 'fr'
})
</script>

<template>
  <div class="wrap">
    <form>
      <span>grid-template-columns</span>
      <div class="controle controle-1">
        <input v-model="controle1" type="range" min="1" max="10" step="1" name="fr">
        <output>{{controle1}}</output>fr
      </div>
      <div class="controle controle-2">
        <input v-model="controle2" type="range" min="1" max="10" step="1" name="fr">
        <output>{{ controle2 }}</output>fr
      </div>
      <div class="controle controle-3">
        <span>220px</span>
      </div>
      <div class="controle controle-4">
        <input  v-model="controle4" type="range" min="1" max="10"  step="1" name="fr">
        <output>{{ controle4 }}</output>fr
      </div>
    </form>
    <div class="container">
      <div class="item">
        CSS is Awesome!
      </div>
      <div class="item">
        W3cplus!
      </div>
      <div class="item">
        <img src="https://loremflickr.com/200/100?random=1" alt="">
      </div>
      <div class="item">
        现代Web布局: CSS Grid Layout!
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.wrap {
  width: 100vw;
  min-height: 100vh;
  font-family: "Exo", Arial, sans-serif;
  background-color: #557;
  color: #fff;
  display: grid;
  place-content: center;
  padding: 1rem;

  form {
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    width: 800px;
    gap: 5px;

    span {
      grid-column: 1 / -1;
    }

    .controle {
      display: inline-flex;
      justify-content: center;
      align-items: center;
    }
  }

  .container {
    --col-1: v-bind(controle1Fr);
    --col-2: v-bind(controle2Fr);
    --col-3: v-bind(controle3Fr);
    --col-4: v-bind(controle4Fr);

    display: grid;
    grid-template-columns: var(--col-1) var(--col-2) var(--col-3) var(--col-4);



    outline: 1px dashed #f36;
    box-shadow: 0 0 0 6px rgb(0 0 0 / 13%);
    border-radius: 1px;
    position: relative;
    width: 800px;
    height: 200px;

    .item {
      display: flex;
      align-items: center;
      padding: 10px;
      background-color: #f7f7f7;
      line-height: 1.65;
      color: #000;

      img {
        display: block;
      }

      &:nth-child(1) {
        background-color: #f1c2c6;
      }
      &:nth-child(2) {
        background-color: #dac2f1;
      }
      &:nth-child(3) {
        background-color: #ccf1c2;
      }
      &:nth-child(4) {
        background-color: #c2e9f1;
      }
    }
  }
}

</style>

